<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('楼层管理')" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>楼层名：</label>
                                <select name="floorName" class="form-control" id="floorName">
                                    <option value="">请选择</option>
                                    <option th:each="a:${sysFloorList}" th:text="${a.floorName}" th:value="${a.floorName}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="query()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="sujian:floorManagement:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="sujian:floorManagement:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="sujian:floorManagement:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-success" onclick="$.table.importExcel()" shiro:hasPermission="sujian:floorManagement:import">
                    <i class="fa fa-upload"></i> 导入
                </a>
                <a class="btn btn-warning" onclick="exportExcel()" shiro:hasPermission="sujian:floorManagement:export">
                    <i class="fa fa-download"></i> 导出
                </a>

            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
     <th:block th:include="include :: footer" />
     <th:block th:include="include :: bootstrap-fileinput-js" />
     <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var options;
        var prefix = ctx + "sujian/floorManagement";
        function query() {
            if(options!=null&&options!=undefined){
                var params = $("#bootstrap-table").bootstrapTable('getOptions');
                $("#bootstrap-table").bootstrapTable('refresh', params);
            }else{
                options = {
                    url: prefix + "/list",
                    createUrl: prefix + "/add",
                    updateUrl: prefix + "/edit/{id}",
                    removeUrl: prefix + "/remove",
                    exportUrl: prefix + "/export",
                    importUrl: prefix + "/importData",
                    importTemplateUrl: prefix + "/importTemplate",
                    uniqueId:"floorId",
                    modalName: "楼层管理信息",
                    // sortName:'num',
                    // sortOrder: 'asc',
                    columns: [{
                        checkbox: true
                    },
                        {
                            field: 'floorId',
                            title: '楼层id',
                            visible: false
                        },
                        {
                            field: 'num',
                            title: '序号',
                            visible: false
                        },
                        {
                            field: 'floorName',
                            title: '楼层名'
                        },
                        {
                            field:'propertyManaParam',
                            title:'物业管参数'
                        },
                        {
                            field:'emptyParam',
                            title:'空关参数'
                        },
                        {
                            field:'waterParam',
                            title:'水费参数'
                        },
                        {
                            field:'fireAirCondition',
                            title:'消防空调(度)'
                        },
                        {
                            field:'sunElecParam',
                            title:'照明电量参数'
                        },
                        {
                            field:'properElecCoef',
                            title:'照明电费用参数'
                        },
                        {
                            field:'powerBatteryParam',
                            title:'动力电量参数'
                        },
                        {
                            field:'pubElecCoef',
                            title:'动力电费用参数'
                        },
                        {
                            field:'eleSchareFeeParam',
                            title:'公用电分摊参数'
                        },
                        {
                            field:'pubElecShareParam',
                            title:'公用电费分摊参数'
                        },
                        {
                            field:'airConditionShareParam',
                            title:'空调电分摊参数'
                        },
                        {
                            field:'airConditionOilParam',
                            title:'空调油费参数'
                        },
                        {
                            field:'oilSum',
                            title:'油费合计'
                        },
                        {
                            field:'updatetime',
                            title:'更新时间'
                        },
                        {
                            field:'remark',
                            title:'备注'
                        }]
                };
                $.table.init(options);
            }
        }

        /*导出接口*/
        function exportExcel(){
            var rows=$.table.selectColumns(table.options.uniqueId);
            if (rows.length == 0) {
                $.modal.alertWarning("请至少选择一条记录");
                return;
            };
            $.modal.confirm("确认要导出选中的" + rows.length + "条数据吗?", function() {
                var url = table.options.exportUrl;
                var data = { "ids": rows.join() };
                $.modal.loading("正在导出数据，请稍后...");
                $.post(url,data,function (res) {
                    if (res.code == web_status.SUCCESS) {
                        window.location.href = ctx + "common/download?fileName=" + encodeURI(res.msg) + "&delete=" + true;
                    } else if (res.code == web_status.WARNING) {
                        $.modal.alertWarning(res.msg)
                    } else {
                        $.modal.alertError(res.msg);
                    }
                    $.modal.closeLoading();
                })
            });
        }

    </script>
</body>

<!-- 导入区域 -->
<script id="importTpl" type="text/template">
    <form enctype="multipart/form-data" class="mt20 mb10">
        <div class="col-xs-offset-1">
            <input type="file" id="file" name="file"/>
            <div class="mt10 pt5">
                <input type="checkbox" id="updateSupport" name="updateSupport" title="如果参数已经存在，更新这条数据。"> 是否更新已经存在的参数数据
                &nbsp;	<a onclick="$.table.importTemplate()" class="btn btn-default btn-xs" shiro:hasPermission="sujian:floorManagement:template"><i class="fa fa-file-excel-o"></i> 下载模板</a>
            </div>
            <font color="red" class="pull-left mt10">
                提示：仅允许导入“xls”或“xlsx”格式文件！！！
            </font>
        </div>
    </form>
</script>

</html>